using System;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;

namespace FU.Capstones.IMS.Web.Common.InventoryServiceProxy.DataContracts
{
    [KnownType(typeof(OrderCriteria))]
    [DataContract(Namespace = WebConstants.ServiceNamespace)]
    public class Order : BindingModelBase<Order>
    {
        public Order()
        {
            AddAllAttributeValidators();
        }

        private int? orderID;
        [DataMember]
        [Key]
        public int? OrderID
        {
            get { return orderID; }
            set
            {
                if(!Equals(orderID,value))
                {
                    orderID = value;
                    RaisePropertyChanged(() => OrderID);
                }
            }
        }
        private int? warehouseID;
        [DataMember]
        [Key]
        public int? WarehouseID
        {
            get { return warehouseID; }
            set
            {
                if (!Equals(warehouseID, value))
                {
                    warehouseID = value;
                    RaisePropertyChanged(() => WarehouseID);
                }
            }
        }

        private string orderCode;
        [DataMember]
        public string OrderCode
        {
            get { return orderCode; }
            set
            {
                if (!ReferenceEquals(orderCode, value))
                {
                    orderCode = value;
                    RaisePropertyChanged(() => OrderCode);
                }
            }
        }

        private DateTime? orderDate;
        [DataMember]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Ngày tạo hóa đơn không đưọc bỏ trống.")]
        public DateTime? OrderDate
        {
            get { return orderDate; }
            set
            {
                if(!Equals(orderDate,value))
                {
                    orderDate = value;
                    RaisePropertyChanged(() => OrderDate);
                }
            }
        }

        private DateTime? deliveryDate;
        [DataMember]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Ngày xuất kho không đưọc bỏ trống.")]
        public DateTime? DeliveryDate
        {
            get { return deliveryDate; }
            set
            {
                if(!Equals(deliveryDate,value))
                {
                    deliveryDate = value;
                    RaisePropertyChanged(() => DeliveryDate);
                }
            }
        }

        private Employee employeeA;
        [DataMember]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Nhân viên thủ kho/phụ trách nhập xuất không đưọc bỏ trống.")]
        public Employee EmployeeA
        {
            get { return employeeA; }
            set
            {
                if(!ReferenceEquals(employeeA,value))
                {
                    employeeA = value;
                    RaisePropertyChanged(() => EmployeeA);
                }
            }
        }

        private Employee employeeB;
        [DataMember]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Nhân viên giao/nhận hàng/vật liệu không đưọc bỏ trống.")]
        public Employee EmployeeB
        {
            get { return employeeB; }
            set
            {
                if (!ReferenceEquals(employeeB, value))
                {
                    employeeB = value;
                    RaisePropertyChanged(() => EmployeeB);
                }
            }
        }

        private Contact contact;
        [DataMember]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Ngừoi đại diện giao/nhận hàng/vật liệu không đưọc bỏ trống.")]
        public Contact Contact
        {
            get { return contact; }
            set
            {
                if(!ReferenceEquals(contact,value))
                {
                    contact = value;
                    RaisePropertyChanged(() => Contact);
                }
            }
        }

        private ObservableCollection<Product> productCollection;
        [DataMember]
        public ObservableCollection<Product> ProductCollection
        {
            get { return productCollection; }
            set
            {
                if(!ReferenceEquals(productCollection,value))
                {
                    productCollection = value;
                    RaisePropertyChanged(() => ProductCollection);
                }
            }
        }

        private ObservableCollection<Material> materialCollection;
        [DataMember]
        public ObservableCollection<Material> MaterialCollection
        {
            get { return materialCollection; }
            set
            {
                if(!ReferenceEquals(materialCollection,value))
                {
                    materialCollection = value;
                    RaisePropertyChanged(() => MaterialCollection);
                }
            }
        }

        private bool? isImported;
        [DataMember]
        public bool? IsImported
        {
            get { return isImported; }
            set
            {
                if(!Equals(isImported,value))
                {
                    isImported = value;
                    RaisePropertyChanged(() => IsImported);
                }
            }
        }

        private bool? isDeleted;
        [DataMember]
        public bool? IsDeleted
        {
            get { return isDeleted; }
            set
            {
                if (!Equals(isDeleted, value))
                {
                    isDeleted = value;
                    RaisePropertyChanged(() => IsDeleted);
                }
            }
        }

        private bool? isMaterial;
        [DataMember]
        public bool? IsMaterial
        {
            get { return isMaterial; }
            set
            {
                if (!Equals(isMaterial, value))
                {
                    isMaterial = value;
                    RaisePropertyChanged(() => IsMaterial);
                }
            }
        }
    }
}
